var express = require('express');
const db = require("../sql");
var router = express.Router();

/* GET users listing. */
// router.get('/', function(req, res, next) {
//     res.send('respond with a resource');
// });

router.post('/', function(req, res, next) {
    let {userName,userPwd}=req.body;
    db.query('select * from user where userName = ? and userPwd = ?',[userName, userPwd],function(err,data){
        if(err){
            throw  err;
        }else if(data.length>0){
            res.status(200);
            res.send({ message: '登录成功' }); // 统一规定的 message
            return;
        }else {}
        res.status(218);
        res.send({ message: '账号或密码错误' });
        return;
    })
});

module.exports = router;